#!/bin/bash
# A2A多智能体Web界面启动脚本

echo "🚀 启动A2A多智能体Web界面..."

# 检查uv是否安装
if ! command -v uv &> /dev/null; then
    echo "❌ uv未安装，请先安装uv: curl -LsSf https://astral.sh/uv/install.sh | sh"
    exit 1
fi

# 进入项目目录
cd "$(dirname "$0")"

# 安装依赖
echo "📦 安装项目依赖..."
uv sync

# 启动Web后端服务
echo "🌐 启动Web后端服务..."
cd web_interface/backend
uv run python web_backend.py &

# 等待服务启动
sleep 3

# 打开浏览器
echo "🔗 打开Web界面..."
if command -v xdg-open &> /dev/null; then
    xdg-open "http://localhost:8000" &
elif command -v open &> /dev/null; then
    open "http://localhost:8000" &
else
    echo "请手动打开浏览器访问: http://localhost:8000"
fi

echo "✅ Web界面启动完成！"
echo "📍 主界面: http://localhost:8000"
echo "📊 数据流可视化: file://$(pwd)/../frontend/data_flow_visualization.html"
echo "🎯 协商界面: file://$(pwd)/../frontend/index.html"
echo ""
echo "按Ctrl+C停止服务"
